import React, { Component } from "react";
import { Route, Switch, Redirect } from "react-router-dom";
import routes from "./router";
import "./App.css";

class App extends Component {
  componentDidMount() {
    // 屏蔽鼠标右键.
    // window.document.oncontextmenu = function () {
    //   return false
    // }
  }
  render() {
    return (
      <div id="app">
        <Switch>
          {routes.map((item) =>
            item.children && item.children.length > 0 ? (
              item.children.map((v) => <Route key={v.path} exact={v.exact} path={v.path} component={v.component} />)
            ) : (
              <Route key={item.path} exact={item.exact} path={item.path} component={item.component} />
            )
          )}
          <Redirect key="redirect" to="/" />
        </Switch>
      </div>
    );
  }
}

export default App;
